$(function(){
	
	var detailId=queryString('updateId');
	var flowId=queryString('taskId');
	//var taskId=queryString('taskId');
	//请求数据详情
	YuXi.Updates.requestDetail(detailId);

	YuXi.Updates.getInformationFlow(detailId);

	YuXi.Updates.init(
		detailId,
		flowId,
		"informationDeploy.jsp",//要返回跳转的页面
		24,//meunId
		""//提交接口
		);
	
	$("#goback").click(function(){	
		window.history.back();
	})

	$(document).on('click','.glyphicon-remove',function(){
		$(this).parent().remove();
	});

		//确认修改按钮
	$("#requestUpdate").click(function(){
		 var text=$("#dispatch-flowId").val();
		
		 if(text=="null"||text==""){
			 myTool.alert({		
					title:"提示",
					context:"请选择要调配到的环节",
					isMask:true,
					
				});
			
		 }else{
			 myTool.alert({		
					title:"提示",
					context:"是否确认调配信息?",
					isMask:true,
					callback:function(){
						inputCondition(text);
					}
				});
		 } 

	})

		function inputCondition(message){
		   YuXi.util.get("DispatchInfo/dispatchInfoToAny.do",{infoId:detailId,flowId:message},function(data){
			   if(data.status){
				   myTool.alert({
					   title:data.subType,
					   context:data.msg
				   });
				   window.history.go(-1);
			   }else{
				   myTool.alert({
					   title:data.subType+"["+data.errorCode+"]",
					   context:data.msg+"[错误代码:"+data.errorCode+']'
				   });
			   }
		   });
			  
	}

	//修改模态框确认按钮
	$("#update").click(function(){
		YuXi.Updates.requestUpdate();//调用修改数据方法
		$("#updateModal").modal('hide');
	})

		
//正则取链接传来的数据
function queryString(key)
{
    var regex_str = "^.+\\?.*?\\b"+ key +"=(.*?)(?:(?=&)|$|#)"
    var regex = new RegExp(regex_str,"i");
    var url = window.location.toString();
    if(regex.test(url)) return RegExp.$1;
    return undefined;
}
function modal(msg,cont){
	myTool.alert({		
		title:msg,
		context:cont,
		isMask:true,
		callback:function(){}
	});
}

})